home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 85 / CD Actual 85 Febrero 2004.iso / Experto / Apache / apache_2.0.48-win32-x86-no_ssl.msi / Data.Cab / F251764_apr_queue.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-02-22  |  6.1 KB  |  180 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  *
  54.  * Portions of this software are based upon public domain software
  55.  * originally written at the National Center for Supercomputing Applications,
  56.  * University of Illinois, Urbana-Champaign.
  57.  */
  58.  
  59. #ifndef APR_QUEUE_H
  60. #define APR_QUEUE_H
  61.  
  62. #if APR_HAS_THREADS
  63. /**
  64.  * @file apr_queue.h
  65.  * @brief Thread Safe FIFO bounded queue
  66.  * @note Since most implementations of the queue are backed by a condition
  67.  * variable implementation, it isn't available on systems without threads.
  68.  * Although condition variables are some times available without threads.
  69.  */
  70.  
  71. #include "apu.h"
  72. #include "apr_errno.h"
  73. #include "apr_pools.h"
  74.  
  75. #ifdef __cplusplus
  76. extern "C" {
  77. #endif /* __cplusplus */
  78.  
  79. /**
  80.  * @defgroup APR_Util_FIFO Thread Safe FIFO bounded queue
  81.  * @ingroup APR_Util
  82.  * @{
  83.  */
  84.  
  85. /**
  86.  * opaque structure
  87.  */
  88. typedef struct apr_queue_t apr_queue_t;
  89.  
  90. /** 
  91.  * create a FIFO queue
  92.  * @param queue The new queue
  93.  * @param queue_capacity maximum size of the queue
  94.  * @param a pool to allocate queue from
  95.  */
  96. APU_DECLARE(apr_status_t) apr_queue_create(apr_queue_t **queue, 
  97.                                            unsigned int queue_capacity, 
  98.                                            apr_pool_t *a);
  99.  
  100. /**
  101.  * push/add a object to the queue, blocking if the queue is already full
  102.  *
  103.  * @param queue the queue
  104.  * @param data the data
  105.  * @returns APR_EINTR the blocking was interrupted (try again)
  106.  * @returns APR_EOF the queue has been terminated
  107.  * @returns APR_SUCCESS on a successfull push
  108.  */
  109. APU_DECLARE(apr_status_t) apr_queue_push(apr_queue_t *queue, void *data);
  110.  
  111. /**
  112.  * pop/get an object from the queue, blocking if the queue is already empty
  113.  *
  114.  * @param queue the queue
  115.  * @param data the data
  116.  * @returns APR_EINTR the blocking was interrupted (try again)
  117.  * @returns APR_EOF if the queue has been terminated
  118.  * @returns APR_SUCCESS on a successfull pop
  119.  */
  120. APU_DECLARE(apr_status_t) apr_queue_pop(apr_queue_t *queue, void **data);
  121.  
  122. /**
  123.  * push/add a object to the queue, returning immediatly if the queue is full
  124.  *
  125.  * @param queue the queue
  126.  * @param data the data
  127.  * @returns APR_EINTR the blocking operation was interrupted (try again)
  128.  * @returns APR_EAGAIN the queue is full
  129.  * @returns APR_EOF the queue has been terminated
  130.  * @returns APR_SUCCESS on a successfull push
  131.  */
  132. APU_DECLARE(apr_status_t) apr_queue_trypush(apr_queue_t *queue, void *data);
  133.  
  134. /**
  135.  * pop/get an object to the queue, returning immediatly if the queue is empty
  136.  *
  137.  * @param queue the queue
  138.  * @param data the data
  139.  * @returns APR_EINTR the blocking operation was interrupted (try again)
  140.  * @returns APR_EAGAIN the queue is empty
  141.  * @returns APR_EOF the queue has been terminated
  142.  * @returns APR_SUCCESS on a successfull push
  143.  */
  144. APU_DECLARE(apr_status_t) apr_queue_trypop(apr_queue_t *queue, void **data);
  145.  
  146. /**
  147.  * returns the size of the queue.
  148.  *
  149.  * @warning this is not threadsafe, and is intended for reporting/monitoring
  150.  * of the queue.
  151.  * @param queue the queue
  152.  * @returns the size of the queue
  153.  */
  154. APU_DECLARE(unsigned int) apr_queue_size(apr_queue_t *queue);
  155.  
  156. /**
  157.  * interrupt all the threads blocking on this queue.
  158.  *
  159.  * @param queue the queue
  160.  */
  161. APU_DECLARE(apr_status_t) apr_queue_interrupt_all(apr_queue_t *queue);
  162.  
  163. /**
  164.  * terminate all queue, sendinging a interupt to all the
  165.  * blocking threads
  166.  *
  167.  * @param queue the queue
  168.  */
  169. APU_DECLARE(apr_status_t) apr_queue_term(apr_queue_t *queue);
  170.  
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174.  
  175. /** @} */
  176.  
  177. #endif /* APR_HAS_THREADS */
  178.  
  179. #endif /* APRQUEUE_H */
  180.